/**
 * 
 */
package com.fyp.ptma.dao.service;

import java.util.List;

import javax.persistence.PersistenceException;

import org.hibernate.HibernateException;
import org.hibernate.exception.ConstraintViolationException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.fyp.ptma.dao.repository.irepository.IGroupDao;
import com.fyp.ptma.dao.service.iservice.IGroupService;
import com.fyp.ptma.model.Application;
import com.fyp.ptma.model.Downloader;
import com.fyp.ptma.model.Group;

/**
 * @author YahyaArshad
 * 
 */
@Service
public class GroupService implements IGroupService {
	@Autowired
	private IGroupDao groupDao;

	@Transactional
	public Long save(Object objToSave) throws PersistenceException,
			ConstraintViolationException {
		// TODO Auto-generated method stub
		return groupDao.save(objToSave);
	}

	@Transactional
	public Long update(Object objToUpdate) throws PersistenceException {
		// TODO Auto-generated method stub
		return groupDao.update(objToUpdate);
	}

	@Transactional
	public boolean delete(Object objToDelete) throws PersistenceException,
			ConstraintViolationException {
		// TODO Auto-generated method stub
		return groupDao.delete(objToDelete);
	}

	@Transactional
	public List<Group> getAllGroups(Application application)
			throws HibernateException {
		// TODO Auto-generated method stub
		return groupDao.getAllGroups(application);
	}

	@Transactional
	public List<Downloader> getAllDownloader(Group group)
			throws HibernateException {
		// TODO Auto-generated method stub
		return groupDao.getAllDownloader(group);
	}

	@Transactional
	public long addDownloaderInGroup(Downloader downloader)
			throws ConstraintViolationException, PersistenceException,
			HibernateException {
		// TODO Auto-generated method stub
		return groupDao.addDownloaderInGroup(downloader);
	}

	@Transactional
	public boolean deleteDownloaderFromGroup(Downloader downloader)
			throws ConstraintViolationException, HibernateException {
		// TODO Auto-generated method stub
		return groupDao.deleteDownloaderFromGroup(downloader);
	}

	@Transactional
	public List<Group> getAllUserGroups(String email) throws HibernateException {
		// TODO Auto-generated method stub
		return groupDao.getAllUserGroups(email);
	}

	@Override
	public void saveOrUpdate(Object objToSave) throws PersistenceException,
			ConstraintViolationException {
		// TODO Auto-generated method stub

	}

}
